package hn.sigit.model.hnd.administrative;

import java.io.Serializable;
import javax.persistence.*;
@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="HND_User", schema="hnd_administrative")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class HND_User implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	public HND_User() {
	}
	
	@Id
	@Column(name="ID", nullable=false)
	private String userName;
	
	@Column(name="Password", nullable=true, length=255)
	private String password;
	
	@Column(name="Active", nullable=false)
	private boolean active;
	
	@OneToMany(mappedBy="user", targetEntity=hn.sigit.model.hnd.administrative.HND_UserRole.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	private java.util.Set<HND_UserRole> roles = new java.util.HashSet<HND_UserRole>();

	@OneToOne(mappedBy="sigitUser", targetEntity=hn.sigit.model.hnd.administrative.HND_NaturalPersonExtParty.class, fetch=FetchType.LAZY)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)	
	private hn.sigit.model.hnd.administrative.HND_NaturalPersonExtParty party;

	
	public String getORMID() {
		return getUserName();
	}

	public void setUserName(String value) {
		this.userName = value;
	}
	public String getUserName() {
		return userName;
	}

	public void setPassword(String value) {
		this.password = value;
	}
	public String getPassword() {
		return password;
	}
	
	public void setActive(boolean value) {
		this.active = value;
	}
	public boolean getActive() {
		return active;
	}
	
	public void setRoles(java.util.Set<HND_UserRole> value) {
		this.roles = value;
	}
	public java.util.Set<HND_UserRole> getRoles() {
		return roles;
	}
	
	public void setParty(hn.sigit.model.hnd.administrative.HND_NaturalPersonExtParty value) {
		this.party = value;
	}
	public hn.sigit.model.hnd.administrative.HND_NaturalPersonExtParty getParty() {
		return party;
	}

	
	public String toString() {
		return String.valueOf(getUserName());
	}
	
	@Transient	
	private boolean _saved = false;
	
	public void onSave() {
		_saved=true;
	}
	
	
	public void onLoad() {
		_saved=true;
	}
	
	
	public boolean isSaved() {
		return _saved;
	}
	
	public boolean equals(Object aObj) {
		if (aObj == this)
			return true;
		if (!(aObj instanceof HND_User))
			return false;
		HND_User HND_User = (HND_User)aObj;
		if ((getUserName() != null && !getUserName().equals(HND_User.getUserName())) || (getUserName() == null && HND_User.getUserName() != null))
			return false;
		return true;
	}
	
	public int hashCode() {
		int hashcode = 0;
		hashcode = hashcode + (getUserName() == null ? 0 : getUserName().hashCode());
		return hashcode;
	}	
}
